package com.tanhua.server.controller;

import com.tanhua.model.vo.SoundVo;
import com.tanhua.server.service.SoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author: Alan_Zhang
 * @Date: 2022/1/8 - 01 - 08 - 15:33
 * @Description: com.tanhua.server.controller
 * @version: 1.0
 */
@RestController
@RequestMapping
public class SoundController {

    @Autowired
    private SoundService soundService;
    /*
     * 桃花传音--接收语音
     * */
    @GetMapping("/peachblossom")
    public ResponseEntity reciveVoice(){
        SoundVo soundVo=soundService.reciveVoice();

        return ResponseEntity.ok(soundVo);
    }
    /*
    * 桃花传音--发送语音
    * */
    @PostMapping("/peachblossom")
    public ResponseEntity sendVoice(@RequestBody MultipartFile soundFile) throws IOException {
        soundService.sendVoice(soundFile);

        return ResponseEntity.ok(null);
    }
}
